Skip to content

Add a margin button to ask the assistant about a paragraph#4328

Open
zenoachtig wants to merge 6 commits into
mainfrom
claude/distracted-engelbart-c85d66
Open

Add a margin button to ask the assistant about a paragraph#4328
zenoachtig wants to merge 6 commits into
mainfrom
claude/distracted-engelbart-c85d66

Conversation

@zenoachtig

Copy link
Copy Markdown
Contributor

Overview

  • Hovering a paragraph (on devices with a fine pointer) now reveals a small assistant icon in the document margin.
  • Clicking it stages the paragraph's text as context and opens the assistant — the same reference flow as the text-selection "Ask" button, but discoverable without selecting anything first.
  • Works for every paragraph, including those nested in lists, steppers, hints, and quotes. Per-block position nudges (declared inline via in-[…] ancestor variants, localized to AskAIParagraphButton) keep it clear of markers/rails/borders; it's hidden inside tables and on touch / hover-less devices.
  • The affordance is purely additive and absolutely positioned, so it never affects document flow, and only renders when the site is in Assistant mode.
  • Generalizes the existing ai_chat_ask_about_page label into a reusable ai_chat_ask_about ("Ask ${1} about ${2}") with new this_page / this_text keys across all locales, so the page action and the paragraph button share one parameterized string.

Demo

Margin button revealed on hover (top-level paragraph):

On nested content (list items):

Clicking stages the paragraph as a reference in the assistant:

— Authored by Claude

@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d6612b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@argos-ci

argos-ci Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2-cloudflare (Inspect) ⚠️ Changes detected (Review) 2 changed, 1 ignored Jul 1, 2026, 1:18 PM
customers-v2-vercel (Inspect) ⚠️ Changes detected (Review) 1 changed Jul 1, 2026, 1:16 PM
v2-cloudflare (Inspect) ✅ No changes detected - Jul 1, 2026, 1:23 PM
v2-vercel (Inspect) ✅ No changes detected 1 ignored Jul 1, 2026, 1:23 PM

zenoachtig and others added 4 commits July 1, 2026 14:41
Make the "ask the assistant about a selection" feature more discoverable by
adding a hover-revealed icon button in the document margin for every paragraph.

- AskAIParagraphButton: an absolutely-positioned, pointer-fine-only button that
  stages the paragraph's text as a chat reference and opens/focuses the assistant.
  Per-block position nudges live in the component via `in-[…]` ancestor variants.
- Paragraph: wrap each paragraph in a `group/ask-ai` container and render the
  button when the site is in Assistant mode (on screen, non-empty paragraphs).
- i18n: generalize `ai_chat_ask_about_page` -> `ai_chat_ask_about` with a
  parameterized target and add `this_page`/`this_text` keys across all locales;
  update PageActions to pass the target.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Show the button at full opacity when revealed instead of dimming it to 50%.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The per-block nudge comment referenced a removed `blockContextOffset` constant;
describe the inline `in-[…]` approach instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Clicking the per-paragraph Ask button now seeds the chat input with an editable
draft ("Tell me more about this") instead of an empty field — staged, focused,
cursor at the end, and not sent, so the reader can tweak or send it.

- useAIChat: add a `draft` state field and a `setDraft` controller method.
- AIChatInput: consume the draft into the (now controlled) input, focus with the
  cursor at the end, then clear the pending draft so it applies once.
- AskAIParagraphButton: stage the draft on click.
- i18n: add `ai_chat_paragraph_draft` across all locales.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the awkward "Ask ${1} about this text" with a dedicated whole-phrase key
(ai_chat_ask_about_this) so each locale reads naturally — e.g. German
"${1} dazu befragen" rather than a stitched "über dies" fragment — while still
using the (variable) assistant name. Drops the now-unused this_text key.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants